<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title><!--{if isset($categoryInfo)}-->修改<!--{else}-->添加<!--{/if}-->商品分类</title>
</head>

<body>
<div style="width:100%">
    <div class="items clearfix">
        <h2 style="" class="tal">
        	正在操作：
        	<!--{if isset($categoryInfo)}-->
        		修改商品分类
        	<!--{else}-->
        		添加商品分类
        	<!--{/if}-->
        </h2>
        <div class="items2">

                <form id="category_form" onsubmit="return false;">
					
					<div class="allTextTime" style="padding-bottom:10px;">
						<div style="margin:8px 0" class="input-group">
							<span style="width: 110px;" class="input-group-addon">分类名称：</span>
							<input type="text" <!--{if isset($categoryInfo)}--> value="<!--{$categoryInfo->description}-->" <!--{else}--> value="" <!--{/if}-->   placeholder="请输入分类名称【必填项】" name="categoryName" id="categoryName" class="form-control hasDatepicker" style="padding-left:8px;">
							<input type="hidden" name="categoryID" id="categoryID" <!--{if isset($categoryInfo)}--> value="<!--{$categoryInfo->id}-->" <!--{else}--> value="" <!--{/if}-->>
						</div>
						
						<div style="margin:8px 0" class="input-group">
							<span style="width: 110px;" class="input-group-addon">上级分类：</span>
							<select placeholder="上级分类" name="parentID" id="parentID" class="form-control hasDatepicker" style="width: 188px;">
								<option value="0_0_1">顶级分类</option>
								<!--{foreach from=$category item=big}-->
									<option value="<!--{$big.bigCategoryID}-->_0_2"><!--{$big.name}--></option>
									
									<!--{foreach from=$big.midCategory item=mid}-->
										<option value="<!--{$big.bigCategoryID}-->_<!--{$mid.midCategoryID}-->_3">&nbsp;&nbsp;&nbsp;&nbsp;└<!--{$mid.name}--></option>
									<!--{/foreach}-->
								<!--{/foreach}-->
							</select>
						</div>
					</div>
                	
                    <!--商品规格组-->
                    <!--{if isset($spec_group)}-->
						<div class="select-box" style="margin-top:30px;">
	                    	<div>规格组</div>
	                    </div>     
	                     <table style="width:97%;border-collapse:collapse;table-layout:fixed;">
							<tr style="height:30px;">
							<!--{assign var="listCount" value=0}-->
							<!--{foreach from=$spec_group item=group_line}-->
								<!--{assign var="isChecked" value=""}-->
								<!--{if isset($category_spec)}-->
									<!--{foreach from=$category_spec item=category_line}-->
										<!--{if $category_line->specGroupID == $group_line->specGroupID}-->
											<!--{assign var="isChecked" value="checked"}-->
										<!--{/if}-->
									<!--{/foreach}-->
								<!--{/if}-->
								<!--{if $listCount>0 && $listCount%3 == 0}-->
									</tr><tr style="height:30px;">
								<!--{/if}-->
								<td style="width:13%;overflow:hidden;white-space:nowrap;padding-left:5px;" title="<!--{$group_line->memo_specGroupName}-->">
									<input style="text-align:left;" type="checkbox" id="chk_<!--{$group_line->specGroupID}-->" name="specGroupID" <!--{$isChecked}--> value="<!--{$group_line->specGroupID}-->">
									<!--{$group_line->specGroupName}-->
								</td>
								<!--{assign var="listCount" value=$listCount+1}-->
							<!--{/foreach}-->
							</tr>
						</table>
					<!--{/if}-->
                    
                    <!--商品标签组-->
                    <!--{if isset($tag_group)}-->
	                    <div class="select-box" style="margin-top:30px;">
	                    	<div>标签组</div>
	                    </div>
	                    <table style="width:97%;border-collapse:collapse;table-layout:fixed;">
							<tr style="height:30px;">
							<!--{assign var="listCount" value=0}-->
							<!--{foreach from=$tag_group item=group_line}-->
								<!--{assign var="isChecked" value=""}-->
								
								<!--{if isset($category_tag)}-->
									<!--{foreach from=$category_tag item=category_line}-->
										<!--{if $category_line->tagGroupID == $group_line->tagGroupID}-->
											<!--{assign var="isChecked" value="checked"}-->
										<!--{/if}-->
									<!--{/foreach}-->
								<!--{/if}-->
								
								<!--{if $listCount>0 && $listCount%7 == 0}-->
									</tr><tr style="height:30px;">
								<!--{/if}-->
								<td style="width:13%;overflow:hidden;white-space:nowrap;padding-left:5px;" title="<!--{$group_line->memo_tagGroupName}-->">
									<input style="text-align:left;" type="checkbox" id="chk_<!--{$group_line->tagGroupID}-->" name="groupID" <!--{$isChecked}--> value="<!--{$group_line->tagGroupID}-->">
									<!--{$group_line->tagGroupName}-->
								</td>
								<!--{assign var="listCount" value=$listCount+1}-->
							<!--{/foreach}-->
							</tr>
						</table>
					<!--{/if}-->
                </form>
            </div>
        </div>
    </div>
	<div style="margin-top:50px;">&nbsp;</div>

    <div class="bottom_fixbox">
        <div class="rectbox tac">
            <input type="button" class="btn" onclick="category.add();" value="<!--{if isset($categoryInfo)}-->修改<!--{else}-->添加<!--{/if}-->分类" />&nbsp;&nbsp;&nbsp;
            <input type="button" class="btn" onclick="E.closeWindows();" value="关闭" />
        </div>
    </div>


</div>

<script type="text/javascript">

	<!--{if isset($categoryInfo)}-->
		$('#parentID').val('<!--{$categoryInfo->parentID}-->');
		$('#parentID option').attr('disabled','true');
	<!--{/if}-->
	
	<!--{if isset($parentID)}-->
		$('#parentID').val('<!--{$parentID}-->');
	<!--{/if}-->

    var category = {

        //保存
        add : function() {
        	
        	this.dt = E.getFormValues('category_form');
        	
        	if (this.dt.categoryName == '') {
        		E.alert('请输入分类名称');
        		return false;
        	}
        	
        	E.loadding.open('请稍等...');
			E.ajax_post({
				url : "/invokingAjax-backend/goods/category.ajax?operFlg=1",
				data : {'params' : this.dt},
				call : 'category.result'
			});
        },
        
        //回调函数
        result : function(o){
        	E.loadding.close();
        	
        	if (o.code == 200) {
        		if (o.data.type == 1) {	//添加
        			E.alert(o.message, 2);
        			E.opener('category.load');
        			category.load();
        		} else {	//编辑
        			$('#input_'+o.data.categoryID).val(o.data.categoryName);
        			E.opener('category.load');
        			E.alert(o.message, 2);
        		}
        		
        	} else {
        		E.alert(o.message);
        	}
        },
        
        load : function(){
        	self.location = '/quanliadmin/app/goods/category.pscript?operFlg=2';
        }
    };

</script>

</body>

</html>
